package org.esti.model.dao;

import org.esti.model.User;

import java.util.List;

/**
 * @author Artem Loginov (logart)
 */

/**
 * DAO is used to getKnowledgeFieldById, save and update objects information in database.
 * This dao manage users.
 */
public interface UserDAO {
    /**
     * Check if user already stored in database.
     * User already stored if user from parameter and any of stored users have same login.
     *
     * @param user which we want to check if it already exist
     * @return true if user exist and false in other way
     */
    boolean isUserExist(User user);

    /**
     * create new user in database
     *
     * @param user which will be stored in db
     * @return user already stored in database
     */
    User add(User user);

    /**
     * retrieve user from db using user login
     *
     * @param login of user we want to getKnowledgeFieldById
     * @return user stored in database with defined login
     */
    User getByLogin(String login);

    /**
     * update user state in db
     *
     * @param user which will be updated
     * @return updated user
     */
    User update(User user);

    /**
     * return list of all users
     * @return list of users
     */
    List<User> getAllUsers();

    /**
     * return user if it have keyword in name surname midlename or email
     * @param keyword search word
     * @return list of filtered user
     */
    List<User> getUsersByKeyWord(String keyword);
}
